/*
    Kelompok    2
    Kelas       2
    Anggota :
    1. Yudha Wastu Prawira      / 13509002
    2. Robertus Theodore        / 13509008
    3. Rendy Bambang Junior     / 13509036
    4. Hartono Sulaiman Wijaya  / 13509046
    5. Daniel Prihartoni        / 13509088
    6. Raydhitya Yosep          / 13509092

*/
#include "Display.h"

//========================================
// Constructor
Display::Display(){
    //inisialisasi display info
	farm.initialize();
	state = APP_STATE;
    this->initialize();
    this->mapping();
    this->displayNow();
    mode = COMMAND_MODE;
}

Display::Display(const Display&){

}
Display::~Display(){

}

void Display::draw(DisplayInfo displayInfo){
    if (displayInfo.state != EXIT_STATE){
        if (displayInfo.state == GAME_STATE){
			farm = displayInfo.farm;
			player = displayInfo.player;
			dwarf1 = displayInfo.waterDwarf;
			dwarf2 = displayInfo.harvestDwarf;
			dwarf3 = displayInfo.slashDwarf;
        }
        state = displayInfo.state;
        message = displayInfo.message;
        prompt = displayInfo.prompt;
        mode = displayInfo.mode;
        this->update();
   }
   else{
            message = displayInfo.message;
            drawMessage();
   }
}


// UPDATE
void Display::update(){
    this->mapping();
    this->displayNow();
}
// INISIALISASI
void Display::initialize(){

    // inisialisasi dictionary
    // ========================
        int width  = 11;
        int height = 11;
        Terrain tempT;

    //ngeresize terrain
        tempT.resize(width);
        for (int i = 0  ; i<= 10; i++){
            tempT[i].resize(height);
        }
        dictionary.insert(make_pair(FARM_CODE,tempT));
        dictionary.insert(make_pair(HOME_CODE,tempT));
        dictionary.insert(make_pair(STORE_CODE,tempT));
    // inisialisasi simbol
    // ========================
        mapSymbols.insert(make_pair(PLAYER_LEFT, "<@O"));
        mapSymbols.insert(make_pair(PLAYER_RIGHT, "O@>"));
        mapSymbols.insert(make_pair(PLAYER_UP, "O^O"));
        mapSymbols.insert(make_pair(PLAYER_DOWN, "OvO"));

        mapSymbols.insert(make_pair(TREE,char(210) + string()+ char(210)+ string()+ char(210)));
        mapSymbols.insert(make_pair(PORTAL,"<X>"));
        mapSymbols.insert(make_pair(SELLER,"<$>"));
        mapSymbols.insert(make_pair(ROAD,"..."));

        mapSymbols.insert(make_pair(DWARF1,"dw1"));
        mapSymbols.insert(make_pair(DWARF2,"dw2"));
        mapSymbols.insert(make_pair(DWARF3,"dw3"));

        mapSymbols.insert(make_pair(FARM_HARVESTED,char(176) + string()+"_"+string()+ char(176)));
        mapSymbols.insert(make_pair(FARM_PLOWED,"_ _"));
        mapSymbols.insert(make_pair(FARM_WATERED,"~~~"));
        mapSymbols.insert(make_pair(FARM_PLOWED_WATERED,"~_~"));
        mapSymbols.insert(make_pair(GRASS,char(176) + string()+ char(176)+ string()+ char(176)));


        mapSymbols.insert(make_pair(FARM_CARROT_SEED,"_w_"));
        mapSymbols.insert(make_pair(FARM_CHILLI_SEED,"_c_"));
        mapSymbols.insert(make_pair(FARM_MELON_SEED,"_m_"));
        mapSymbols.insert(make_pair(FARM_STRAWBERRY_SEED,"_s_"));
        mapSymbols.insert(make_pair(FARM_CARROT_SEED,"_t_"));

        mapSymbols.insert(make_pair(FARM_CARROT_SEED_WATERED,"~w~"));
        mapSymbols.insert(make_pair(FARM_CHILLI_SEED_WATERED,"~c~"));
        mapSymbols.insert(make_pair(FARM_MELON_SEED_WATERED,"~m~"));
        mapSymbols.insert(make_pair(FARM_STRAWBERRY_SEED_WATERED,"~s~"));
        mapSymbols.insert(make_pair(FARM_TOMATO_SEED_WATERED,"~t~"));

        mapSymbols.insert(make_pair(FARM_CARROT_ADULT,"_W_"));
        mapSymbols.insert(make_pair(FARM_CHILLI_ADULT,"_C_"));
        mapSymbols.insert(make_pair(FARM_MELON_ADULT,"_M_"));
        mapSymbols.insert(make_pair(FARM_STRAWBERRY_ADULT,"_S_"));
        mapSymbols.insert(make_pair(FARM_CARROT_ADULT,"_T_"));

        mapSymbols.insert(make_pair(FARM_CARROT_ADULT_WATERED,"~W~"));
        mapSymbols.insert(make_pair(FARM_CHILLI_ADULT_WATERED,"~C~"));
        mapSymbols.insert(make_pair(FARM_MELON_ADULT_WATERED,"~M~"));
        mapSymbols.insert(make_pair(FARM_STRAWBERRY_ADULT_WATERED,"~S~"));
        mapSymbols.insert(make_pair(FARM_TOMATO_ADULT_WATERED,"~T~"));

        mapSymbols.insert(make_pair(FARM_CARROT_FRUITED,"@W@"));
        mapSymbols.insert(make_pair(FARM_CHILLI_FRUITED,"@C@"));
        mapSymbols.insert(make_pair(FARM_MELON_FRUITED,"@M@"));
        mapSymbols.insert(make_pair(FARM_STRAWBERRY_FRUITED,"@S@"));
        mapSymbols.insert(make_pair(FARM_TOMATO_FRUITED,"@T@"));

        mapSymbols.insert(make_pair(DWARF1_UP,"d^1"));
        mapSymbols.insert(make_pair(DWARF1_RIGHT,"d1>"));
        mapSymbols.insert(make_pair(DWARF1_LEFT,"<d1"));
        mapSymbols.insert(make_pair(DWARF1_DOWN,"dv1"));

        mapSymbols.insert(make_pair(DWARF2_UP,"d^2"));
        mapSymbols.insert(make_pair(DWARF2_RIGHT,"d2>"));
        mapSymbols.insert(make_pair(DWARF2_LEFT,"<d2"));
        mapSymbols.insert(make_pair(DWARF2_DOWN,"dv2"));

        mapSymbols.insert(make_pair(DWARF3_UP,"d^3"));
        mapSymbols.insert(make_pair(DWARF3_RIGHT,"d3>"));
        mapSymbols.insert(make_pair(DWARF3_LEFT,"<d3"));
        mapSymbols.insert(make_pair(DWARF3_DOWN,"dv3"));

}



void Display::mapping(){
    di = dictionary.find(FARM_CODE); // dictionary iterator
    ti = (di->second).begin(); // terrain iterator for dictionary
    // dictionary dengan key 2 ...
    // mapping simbol untuk elemen non-farm
    int playerX = (int) player.getCurPos().x;
	int playerY = (int) player.getCurPos().y;
	int playerDirection = player.getCurDir(); // Posisi Player

    int portalX = DEFAULT_PORTAL_X;    int portalY = DEFAULT_PORTAL_Y;
    int sellerX = DEFAULT_SELLING_POINT_X;    int sellerY = DEFAULT_SELLING_POINT_Y;

    int dwarf1X = dwarf1.getCurPos().x;    int dwarf1Y = dwarf1.getCurPos().y;
    int dwarf2X = dwarf2.getCurPos().x;    int dwarf2Y = dwarf2.getCurPos().y;
    int dwarf3X = dwarf3.getCurPos().x;    int dwarf3Y = dwarf3.getCurPos().y;

    MI roadIterator = mapSymbols.find(ROAD);
    MI grassIterator = mapSymbols.find(GRASS);
	MI tempIterator;
    string str;
    VI vi;
    Point coordinate;

 // mapping simbol untuk elemen farm
    if (!dictionary.empty()){

            FarmPlan tempFarmPlan;
            tempFarmPlan   = farm.getFarmPlan();
            PlantType tipe;

            for (int i = 0; i<= 10; i++){
                coordinate.x = i;
                vi = (*ti).begin(); // vector iterator for terrain
                for (int j = 0 ; j<= 10 ; j++){

                    if (tempFarmPlan[i][j].plantable == true){
                        coordinate.y = j;
                        if (tempFarmPlan[i][j].plant != NULL){
                             tipe = (tempFarmPlan[i][j]).plant->getPlantType();

                             if (tipe == TREE) {
                                tempIterator = mapSymbols.find(TREE) ;
                                str = tempIterator->second;
                                *vi =  str;
                            } else if (tipe == CARROT_PLANT_CODE){
                                if ((tempFarmPlan[i][j]).plant->getAgeLeft() > 0){
                                    if ((tempFarmPlan[i][j]).plant->getHappyMeter() < CARROT_ADULT_POINT){
                                        if ((tempFarmPlan[i][j]).watered != true){
                                            tempIterator = mapSymbols.find(FARM_CARROT_SEED);
                                        } else {
                                            tempIterator = mapSymbols.find(FARM_CARROT_SEED_WATERED);
                                        }

                                    } else {
                                        if ((tempFarmPlan[i][j]).plant->getHappyMeter() < CARROT_HARVEST_POINT){
                                            if ((tempFarmPlan[i][j]).watered != true){
                                                tempIterator = mapSymbols.find(FARM_CARROT_ADULT);
                                            } else {
                                                tempIterator = mapSymbols.find(FARM_CARROT_ADULT_WATERED);
                                            }
                                        } else {
                                            // saatnya diharvest -> fruited
                                            tempIterator = mapSymbols.find(FARM_CARROT_FRUITED);
                                        }
                                    }
                                } else {
                                    // plant die
                                    tempIterator = mapSymbols.find(FARM_HARVESTED);
                                }
                                str = tempIterator->second;
                                *vi =  str;
                            }else if (tipe == CHILLI_PLANT_CODE){
                                if ((tempFarmPlan[i][j]).plant->getAgeLeft() > 0){
                                    if ((tempFarmPlan[i][j]).plant->getHappyMeter() < CHILLI_ADULT_POINT){
                                        if ((tempFarmPlan[i][j]).watered != true){
                                            tempIterator = mapSymbols.find(FARM_CHILLI_SEED);
                                        } else {
                                            tempIterator = mapSymbols.find(FARM_CHILLI_SEED_WATERED);
                                        }

                                    } else {
                                        if ((tempFarmPlan[i][j]).plant->getHappyMeter() < CHILLI_HARVEST_POINT){
                                            if ((tempFarmPlan[i][j]).watered != true){
                                                tempIterator = mapSymbols.find(FARM_CHILLI_ADULT);
                                            } else {
                                                tempIterator = mapSymbols.find(FARM_CHILLI_ADULT_WATERED);
                                            }
                                        } else {
                                            // saatnya diharvest -> fruited
                                            tempIterator = mapSymbols.find(FARM_CHILLI_FRUITED);
                                        }
                                    }
                                } else {
                                    // plant die
                                    tempIterator = mapSymbols.find(FARM_HARVESTED);
                                }
                                str = tempIterator->second;
                                *vi =  str;
                            }else if (tipe == MELON_PLANT_CODE){
                                if ((tempFarmPlan[i][j]).plant->getAgeLeft() > 0){
                                    if ((tempFarmPlan[i][j]).plant->getHappyMeter() < MELON_ADULT_POINT){
                                        if ((tempFarmPlan[i][j]).watered != true){
                                            tempIterator = mapSymbols.find(FARM_MELON_SEED);
                                        } else {
                                            tempIterator = mapSymbols.find(FARM_MELON_SEED_WATERED);
                                        }

                                    } else {
                                        if ((tempFarmPlan[i][j]).plant->getHappyMeter() < MELON_HARVEST_POINT){
                                            if ((tempFarmPlan[i][j]).watered != true){
                                                tempIterator = mapSymbols.find(FARM_MELON_ADULT);
                                            } else {
                                                tempIterator = mapSymbols.find(FARM_MELON_ADULT_WATERED);
                                            }
                                        } else {
                                            // saatnya diharvest -> fruited
                                            tempIterator = mapSymbols.find(FARM_MELON_FRUITED);
                                        }
                                    }
                                } else {
                                    // plant die
                                    tempIterator = mapSymbols.find(FARM_HARVESTED);
                                }
                                str = tempIterator->second;
                                *vi =  str;
                            }else if (tipe == STRAWBERRY_PLANT_CODE){
                                if ((tempFarmPlan[i][j]).plant->getAgeLeft() > 0){
                                    if ((tempFarmPlan[i][j]).plant->getHappyMeter() < STRAWBERRY_ADULT_POINT){
                                        if ((tempFarmPlan[i][j]).watered != true){
                                            tempIterator = mapSymbols.find(FARM_STRAWBERRY_SEED);
                                        } else {
                                            tempIterator = mapSymbols.find(FARM_STRAWBERRY_SEED_WATERED);
                                        }

                                    } else {
                                        if ((tempFarmPlan[i][j]).plant->getHappyMeter() < STRAWBERRY_HARVEST_POINT){
                                            if ((tempFarmPlan[i][j]).watered != true){
                                                tempIterator = mapSymbols.find(FARM_STRAWBERRY_ADULT);
                                            } else {
                                                tempIterator = mapSymbols.find(FARM_STRAWBERRY_ADULT_WATERED);
                                            }
                                        } else {
                                            // saatnya diharvest -> fruited
                                            tempIterator = mapSymbols.find(FARM_STRAWBERRY_FRUITED);
                                        }
                                    }
                                } else {
                                    // plant die
                                    tempIterator = mapSymbols.find(FARM_HARVESTED);
                                }
                                str = tempIterator->second;
                                *vi =  str;
                            }else if (tipe == TOMATO_PLANT_CODE){
                                if ((tempFarmPlan[i][j]).plant->getAgeLeft() > 0){
                                    if ((tempFarmPlan[i][j]).plant->getHappyMeter() < TOMATO_ADULT_POINT){
                                        if ((tempFarmPlan[i][j]).watered != true){
                                            tempIterator = mapSymbols.find(FARM_TOMATO_SEED);
                                        } else {
                                            tempIterator = mapSymbols.find(FARM_TOMATO_SEED_WATERED);
                                        }

                                    } else {
                                        if ((tempFarmPlan[i][j]).plant->getHappyMeter() < TOMATO_HARVEST_POINT){
                                            if ((tempFarmPlan[i][j]).watered != true){
                                                tempIterator = mapSymbols.find(FARM_TOMATO_ADULT);
                                            } else {
                                                tempIterator = mapSymbols.find(FARM_TOMATO_ADULT_WATERED);
                                            }
                                        } else {
                                            // saatnya diharvest -> fruited
                                            tempIterator = mapSymbols.find(FARM_TOMATO_FRUITED);
                                        }
                                    }
                                } else {
                                    // plant die
                                    tempIterator = mapSymbols.find(FARM_HARVESTED);
                                }
                                str = tempIterator->second;
                                *vi =  str;
                            }
                        } else {
                            // if plant is null

                            if (((tempFarmPlan[i][j]).plowed == true)&& ((tempFarmPlan[i][j]).watered == true)){
                                tempIterator = mapSymbols.find(FARM_PLOWED_WATERED);
                                *vi = tempIterator->second;
//                            } else if (((tempFarmPlan[i][j]).plowed == false)&&((tempFarmPlan[i][j]).watered == true)) {
//                                tempIterator = mapSymbols.find(FARM_WATERED);
//                                *vi = tempIterator->second;
                            } else if (((tempFarmPlan[i][j]).plowed == false)&&((tempFarmPlan[i][j]).watered == false)){
                                *vi =   grassIterator->second;
                            } else if (((tempFarmPlan[i][j]).plowed == true)&&((tempFarmPlan[i][j]).watered == false)){
                                tempIterator = mapSymbols.find(FARM_PLOWED);
                                *vi = tempIterator->second;
                            }

                        }
                        //tipe = (*tempPlant).getPlantType();
                        //tipe = GRASS;

                        if ((i == playerX) && (j == playerY)){
                            *vi = (mapSymbols.find(playerDirection))->second;
                        } else if ((i == dwarf1X)&&(j == dwarf1Y)){
                            if (dwarf1.getStatus() == SLEEP){
                                *vi = (mapSymbols.find(DWARF1))->second;
                            } else
                                if (dwarf1.getCurDir() == UP){
                                    *vi = (mapSymbols.find(DWARF1_UP))->second;
                                } else if (dwarf1.getCurDir() == RIGHT){
                                    *vi = (mapSymbols.find(DWARF1_RIGHT))->second;
                                } else if (dwarf1.getCurDir() == LEFT){
                                    *vi = (mapSymbols.find(DWARF1_LEFT))->second;
                                } else if (dwarf1.getCurDir() == DOWN){
                                    *vi = (mapSymbols.find(DWARF1_DOWN))->second;
                                }
                        }else if ((i == dwarf2X)&&(j == dwarf2Y)){
                            if (dwarf2.getStatus() == SLEEP){
                                *vi = (mapSymbols.find(DWARF2))->second;
                            } else
                                if (dwarf2.getCurDir() == UP){
                                    *vi = (mapSymbols.find(DWARF2_UP))->second;
                                } else if (dwarf2.getCurDir() == RIGHT){
                                    *vi = (mapSymbols.find(DWARF2_RIGHT))->second;
                                } else if (dwarf2.getCurDir() == LEFT){
                                    *vi = (mapSymbols.find(DWARF2_LEFT))->second;
                                } else if (dwarf2.getCurDir() == DOWN){
                                    *vi = (mapSymbols.find(DWARF2_DOWN))->second;
                                }
                        }else if ((i == dwarf3X)&&(j == dwarf3Y)){
                            if (dwarf3.getStatus() == SLEEP){
                                *vi = (mapSymbols.find(DWARF3))->second;
                            } else
                                if (dwarf3.getCurDir() == UP){
                                    *vi = (mapSymbols.find(DWARF3_UP))->second;
                                } else if (dwarf3.getCurDir() == RIGHT){
                                    *vi = (mapSymbols.find(DWARF3_RIGHT))->second;
                                } else if (dwarf3.getCurDir() == LEFT){
                                    *vi = (mapSymbols.find(DWARF3_LEFT))->second;
                                } else if (dwarf3.getCurDir() == DOWN){
                                    *vi = (mapSymbols.find(DWARF3_DOWN))->second;
                                }
                        }

                    } else {
                            if ((i == playerX) && (j == playerY)){
                                *vi = (mapSymbols.find(playerDirection))->second;
                            }else if ((i == dwarf1X)&&(j == dwarf1Y)){
                                if (dwarf1.getStatus() == SLEEP){
                                    *vi = (mapSymbols.find(DWARF1))->second;
                                } else
                                    if (dwarf1.getCurDir() == UP){
                                        *vi = (mapSymbols.find(DWARF1_UP))->second;
                                    } else if (dwarf1.getCurDir() == RIGHT){
                                        *vi = (mapSymbols.find(DWARF1_RIGHT))->second;
                                    } else if (dwarf1.getCurDir() == LEFT){
                                        *vi = (mapSymbols.find(DWARF1_LEFT))->second;
                                    } else if (dwarf1.getCurDir() == DOWN){
                                        *vi = (mapSymbols.find(DWARF1_DOWN))->second;
                                    }
                            }else if ((i == dwarf2X)&&(j == dwarf2Y)){
                                if (dwarf2.getStatus() == SLEEP){
                                    *vi = (mapSymbols.find(DWARF2))->second;
                                } else
                                    if (dwarf2.getCurDir() == UP){
                                        *vi = (mapSymbols.find(DWARF2_UP))->second;
                                    } else if (dwarf2.getCurDir() == RIGHT){
                                        *vi = (mapSymbols.find(DWARF2_RIGHT))->second;
                                    } else if (dwarf2.getCurDir() == LEFT){
                                        *vi = (mapSymbols.find(DWARF2_LEFT))->second;
                                    } else if (dwarf2.getCurDir() == DOWN){
                                        *vi = (mapSymbols.find(DWARF2_DOWN))->second;
                                    }
                            }else if ((i == dwarf3X)&&(j == dwarf3Y)){
                                if (dwarf3.getStatus() == SLEEP){
                                    *vi = (mapSymbols.find(DWARF3))->second;
                                } else
                                    if (dwarf3.getCurDir() == UP){
                                        *vi = (mapSymbols.find(DWARF3_UP))->second;
                                    } else if (dwarf3.getCurDir() == RIGHT){
                                        *vi = (mapSymbols.find(DWARF3_RIGHT))->second;
                                    } else if (dwarf3.getCurDir() == LEFT){
                                        *vi = (mapSymbols.find(DWARF3_LEFT))->second;
                                    } else if (dwarf3.getCurDir() == DOWN){
                                        *vi = (mapSymbols.find(DWARF3_DOWN))->second;
                                    }
                            }
                             else if ((i == portalX)&&(j == portalY)){
                                *vi = (mapSymbols.find(PORTAL))->second;
                            } else if ((i == sellerX)&&(j == sellerY)){
                                *vi = (mapSymbols.find(SELLER))->second;
                            } else {
                                str = roadIterator->second;
                                *vi = str;
                             }
                    }
                    vi++;

                }
                ti++;
            }
        }
}

void Display::displayNow(){

    // Kamus
        int infoCode ;
        int codeArea ;
    // inisialisasi
        codeArea = player.getCurArea();
    // clear screen
        system("CLS");
    // Display game title
        SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY  | 12 | BACKGROUND_INTENSITY |
                                 BACKGROUND_RED |BACKGROUND_GREEN  |BACKGROUND_BLUE );
        string title = " _   _    _    ____  ____  _____ ____  __  __ _   _ _   _ \n| | | |  / \\  |  _ \\|  _ \\| ____/ ___||  \\/  | | | | \\ | |\n| |_| | / _ \\ | |_) | |_) |  _| \\___ \\| |\\/| | | | |  \\| |\n|  _  |/ ___ \\|  _ <|  __/| |___ ___) | |  | | |_| | |\\  |\n|_| |_/_/   \\_\\_| \\_\\_|   |_____|____/|_|  |_|\\___/|_| \\_|\n";
        cout <<title <<"                                                          \n"<<
        "                                                          \n";

    // Display main body
        // if state is play mode then
        // Display isi area
        if (state == GAME_STATE){
            if (codeArea == FARM_CODE){
                // drawFarm
                infoCode = INFORMATION_FARM_HELP;
                this->drawFarm();
            } else if(codeArea == HOME_CODE) {
                // drawHome
				infoCode = INFORMATION_HOME_HELP;
                this->drawHome();
            } else if (codeArea == STORE_CODE) {
                // drawStore
                this->drawStore();
                infoCode = INFORMATION_STORE_HELP;
            }
        } else if (state == APP_STATE) {
            // else if state is menu mode then
            infoCode = INFORMATION_APP_HELP;
        }
    // Display Information
        drawInformation(infoCode);
        drawMessage();
    // Display prompt for parser
        drawPrompt();
}

void Display::drawInformation(int informationCode){

//blue=1, green, cyan, red, purple, yellow, grey, dgrey, hblue, hgreen 10, hblue 11 , hred 12, hpurple,
    // hyellow 14, hwhite 15
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 7);
    cout << endl ;

    cout << "\t\t  INFORMATION" << endl;
    cout << "================================================" << endl;
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 11);
    switch (informationCode){
        case INFORMATION_FARM_HELP :{
            cout << " WELCOME TO FARM, "<< player.getName()<<" !!! \n";
            cout << " LEGEND\n";
            cout << " Grass  : " << (mapSymbols.find(GRASS))->second <<  " Tree    : " << (mapSymbols.find(TREE))->second << endl;
            cout << " Player : " << (mapSymbols.find(PLAYER_UP))->second << " Dwarf   : " << (mapSymbols.find(DWARF1))->second << endl;
            cout << " Road   : " << (mapSymbols.find(ROAD))->second   << " Portal  : " << (mapSymbols.find(PORTAL))->second << endl;
            cout << " Seller : " << (mapSymbols.find(SELLER))->second << endl;
            cout << endl;
            cout << endl;
            break;
        }
        case INFORMATION_APP_HELP:{
            cout << "Welcome to Main Menu!\n";
            cout << "New Game  = new <your_name> #\n";
            cout << "Load Game = load <file_name> #\n";
            cout << "Help      = teleport -help #\n";
            cout << "Exit App  = exit #\n";
            cout << endl;
            break;
        }
        case INFORMATION_HOME_HELP:{
            cout << "Home sweet home!\n";
            cout << "What will you do??\n";
            cout << "Sleep          = sleep #\n";
            cout << "Save           = save #\n";
            cout << "Exit Home      = teleport farm #\n";
            cout << "Exit Game      = exit #\n";
            cout << endl;
            break;
        }
        case INFORMATION_STORE_HELP:{
            cout << "Hello, "<< player.getName()<<" , Welcome to RBJ store\n";
            cout << "What will you do in my store??\n";
            cout << "To see our item's list = store#\n";
            cout << "To buy new item        = buy <item_name> <amount>#\n";
            cout << "To sell your item      = sell <item_slot> <amount>#\n";
            cout << "Exit Store             = teleport farm #\n";
            cout << endl;
            cout << endl;
            break;
        }
    }
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 7);
    cout << "================================================" << endl;
}
void Display::drawMessage(){

    cout << "================================================" << endl;
    cout << "_____________________MESSAGE____________________" << endl;
    cout << endl;

    if (message.size() != 0){
        for(vi = message.begin(); vi!=message.end() ; ++vi){
			cout << (*vi)<< endl;
        }
    } else {
        cout << "No Message\n";
    }
    cout << "================================================" << endl;
}
void Display::drawPrompt(){
//    int key ;
    //state = this->mode;
    if (state == GAME_STATE){
    // if state is play mode
//        cout << "SELECT MODE = \n" ;
//        cout << "Press arrow   for EXPLORER MODE\n";
//        cout << "Press any key for COMMAND MODE\n" ;
        cout << "\n>Play>";
       // key = getch();
            if (mode == ADVENTURE_MODE ){
                cout << "Explorer> ";
//                cout << "Explorer mode success " << endl;
            } else if (mode == COMMAND_MODE){
                cout << "Command> ";
                //inputCommand.update();
            }
    } else if (state == APP_STATE){
    // if state is menu mode
        cout << "\n>Menu> ";
    }

}
void Display::drawFarm(){

    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 10);
    cout << "\n\t\t      FARM" << endl;
    cout << "Name       : "<< player.getName() << "\t\t Money : "<< player.getBalance()<< endl;
    cout << "Time Left  : "<< player.getTimeLeft() << endl;
    cout << "Days       : "<< player.getDay() << endl;
    cout << "Weather    : ";
        if (player.getDay() % 5 == 0){
            cout << "Rainy" << endl;
        } else if(player.getDay()% 15 == 0){
            cout << "Storm" << endl;
        } else
            cout << "Sunny" << endl;


    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 14);
    cout << endl;
    cout << "================================================" << endl;
    di = dictionary.find(FARM_CODE); // dictionary iterator sudah menunjuk kepada farm
    ti = (di->second).begin(); // terrain iterator for dictionary
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 0 | BACKGROUND_INTENSITY | BACKGROUND_GREEN);
    for ( ti = (di->second).begin(); ti != (di->second).end(); ti++){
        // cout border
        cout<< "| ";
        // cout elemen
        for (vi = (*ti).begin(); vi!= (*ti).end(); vi++){
            cout << *vi<< " ";
        }
        cout<< " |\n";
        cout << "                                                \n";
        cout << "                                                \n";
    }
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 14);
    cout << "================================================" << endl;
}
void Display::drawHome(){
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 10);
    cout << "\n\t\t   HOME" << endl;
    cout << "Name       : "<< player.getName() << "\t\t Money : "<< player.getBalance()<< endl;
    cout << "Time Left  : "<< player.getTimeLeft() << endl;
    cout << "Days       : "<< player.getDay() << endl;
    cout << "Weather    : ";
        if (player.getDay() % 5 == 0){
            cout << "Rainy" << endl;
        } else if(player.getDay()% 15 == 0){
            cout << "Storm" << endl;
        } else
            cout << "Sunny" << endl;
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 9);
    cout << endl;
    cout << "================================================" << endl;
        // isi home
    string picture =
        "....                                    \n....    ....... ..7M                    \n.................7MIM~.    . ..         \n................MM   MM.                \n..............~M . .. MM   . .          \n    .....    .MI      .MM             ..\n    .....   DM          MM.           ..\n    .....  M8            8MZ          ..\n    ..... M+.             .MM           \n    ....,M                  NM.         \n    ...MM                    MMO        \n     .MM+                     =M,   ....\n     MN                         M,  ....\n   8M$                           M8 ....\n  7MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM....\n   M$                .       .    MM....\n   M$                             MM....\n   M$                .       .    MM....\n   M$                             MM....\n   M$                             MM....\n   M$                .            MM....\n   M7.       NMMMMMMMMMMN         MM....\n   M$        NO   . ...8N.. ......MM. . \n.  M$     .  NO.  .....8N.........MM    \n   M$        NO      ..8N.. ......MM    \n.  M$     .  NO.  .....8N.........MM    \n   M$        NO   . ...8N.. ......MM    \n.  M$     .  NO.  .....8N.........MM. . \n   M$        NO      ..8N.. ......MM. . \n.  M$.    .  NO.  .....8N.........MM... \n   M7        NDIIIIIIIIDN         MM... \n.  MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM    \n          .    .  ................... . \n";
    cout << picture;

    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 9);
    cout << endl;
    cout << "================================================" << endl;

}
void Display::drawStore(){
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 10);
    cout << "\n\t\t   STORE" << endl;
    cout << "Name       : "<< player.getName() << "\t\t Money : "<< player.getBalance()<< endl;
    cout << "Time Left  : "<< player.getTimeLeft() << endl;
    cout << "Days       : "<< player.getDay() << endl;
    cout << "Weather    : ";
        if (player.getDay() % 5 == 0){
            cout << "Rainy" << endl;
        } else if(player.getDay()% 15 == 0){
            cout << "Storm" << endl;
        } else
            cout << "Sunny" << endl;
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 9);
    cout << endl;
    cout << "================================================" << endl;

    string picture =
        "...                        ..... .......\n                           .  .     .   \n        MMMMMMMMMMMMMMMMMMMMMMMMMM.     \n        MM  .    .        .     MM.     \n      ..MM   . .           .....MM......\n  . . ..MM..MMMMMMMMM...........MM......\n      ..MM   .             .....MM......\n  .   ..MM....             .....MM......\n   .. ..MM......................MM......\n .......MM......................MM......\n   .  ..MM......................MM......\n   .  ..MMMMMMMMMMMMMMMMMMMMMMMMMM......\n   .  .. MMMMMMMMMMMMMMMMMMMMMMMMMM.....\n   .  ZM$    . ................?MD?.....\n   .MM.......................,M?.I?.....\nNM........................NM....I?.....\nMMMMMMMMMMMMMMMMMMMMMMMMMMM~.....I?.....\nM.           . . .. .    M=......I?.....\nM  .  .. .   . ......... M=......I?.....\nM     ..       .         M=......I+ ....\nM. .  .        .         M=..... MM ....\nM              .         M=....MM.......\nM  .  .. .   . ......... M=...M.........\nM              .         M=DM ..........\nMMMMMMMMMMMMMMMMMMMMMMMMMMM.............\n.  .. .   . ......... ...............\n.  .. .   . ......... ...............\n";
    cout << picture;
    SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 9);
    cout << endl;
    cout << "================================================" << endl;
}


